package com.yanqu.road.server.manager.tomb.entity;

import com.yanqu.road.dao.dbV2.BaseEntity;
import com.yanqu.road.dao.dbV2.IField;
import com.yanqu.road.dao.dbV2.ITable;
import com.yanqu.road.dao.dbV2.serializer.DInt;
import com.yanqu.road.dao.dbV2.serializer.DLong;
import com.yanqu.road.dao.dbV2.serializer.DObject;
import com.yanqu.road.dao.dbV2.serializer.DString;
import com.yanqu.road.logic.activity.tomb.config.entity.EventInfo;
import com.yanqu.road.server.manager.tomb.Maze;

import java.util.ArrayList;
import java.util.List;

@ITable(tableName = "t_c_activity_tomb_maze")
public class DbTombMaze extends BaseEntity {

    public static DbTombMaze newInstance() {
        return new DbTombMaze();
    }

    @IField(isPrimaryKey = true, fieldName = "activity_id", serializer = DInt.class)
    public int activityId;

    @IField(isPrimaryKey = true, fieldName = "groupId", comment = "分组", serializer = DInt.class)
    public int groupId;

    @IField(isPrimaryKey = true, fieldName = "floor", comment = "层数", serializer = DInt.class)
    public int floor;

    @IField(fieldName = "elite_event_id", comment = "该层的守关", serializer = DInt.class)
    public int eliteEventId;

    @IField(fieldName = "elite_npc_event", comment = "守关精英位置", serializer = DString.class)
    public String eliteNpcEvent = "";

    @IField(fieldName = "maze", comment = "地图信息", serializer = DObject.class)
    public Maze maze;

    @IField(fieldName = "first_into", comment = "第一个进入地图的用户", serializer = DLong.class)
    public long firstIntoUserId;

    @IField(fieldName = "generate_event_num", comment = "生成的事件数量", serializer = DInt.class)
    public int generateEventNum;

    @IField(fieldName = "brake_big_grip_num", comment = "破坏的完整格子数量", serializer = DInt.class)
    public int brakeBigGripNum;

    @IField(fieldName = "explored_big_event_num", comment = "探索到的9格事件", serializer = DInt.class)
    public int exploredBigEventNum;

    @IField(fieldName = "explored_normal_event_num", comment = "探索到的1格事件", serializer = DInt.class)
    public int exploredNormalEventNum;

    @IField(fieldName = "event_info_list", comment = "探索到的1格事件", serializer = DObject.class)
    public List<EventInfo> eventInfoList = new ArrayList<>();

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getFloor() {
        return floor;
    }

    public void setFloor(int floor) {
        this.floor = floor;
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        this.groupId = groupId;
    }

    public Maze getMaze() {
        return maze;
    }

    public void setMaze(Maze maze) {
        this.maze = maze;
    }

    public String getEliteNpcEvent() {
        return eliteNpcEvent;
    }

    public void setEliteNpcEvent(String eliteNpcEvent) {
        this.eliteNpcEvent = eliteNpcEvent;
    }

    public Long getFirstIntoUserId() {
        return firstIntoUserId;
    }

    public void setFirstIntoUserId(Long firstIntoUserId) {
        this.firstIntoUserId = firstIntoUserId;
    }

    public int getBrakeBigGripNum() {
        return brakeBigGripNum;
    }

    public void setBrakeBigGripNum(int brakeBigGripNum) {
        this.brakeBigGripNum = brakeBigGripNum;
    }

    public void increaseBrakeBigGripNum() {
        this.brakeBigGripNum++;
    }


    public void addExplored(int eventId) {
        for (EventInfo eventInfo : this.eventInfoList) {
            if (eventInfo.getEventId() == eventId) {
                eventInfo.setExploredNum(eventInfo.getExploredNum() + 1);
                return;
            }
        }
    }

    public void addEventDone(int eventId) {
        for (EventInfo eventInfo : this.eventInfoList) {
            if (eventInfo.getEventId() == eventId) {
                eventInfo.setDoneNum(eventInfo.getDoneNum() + 1);
                return;
            }
        }
    }

    public int acquireExploredNum(int eventId) {
        for (EventInfo eventInfo : this.eventInfoList) {
            if (eventInfo.getEventId() == eventId) {
                return eventInfo.getExploredNum();
            }
        }
        return 0;
    }

    public void setFirstIntoUserId(long firstIntoUserId) {
        this.firstIntoUserId = firstIntoUserId;
    }

    public int getExploredBigEventNum() {
        return exploredBigEventNum;
    }

    public void setExploredBigEventNum(int exploredBigEventNum) {
        this.exploredBigEventNum = exploredBigEventNum;
    }

    public void increaseExploredBigEventNum() {
        this.exploredBigEventNum++;
    }

    public int getExploredNormalEventNum() {
        return exploredNormalEventNum;
    }

    public void setExploredNormalEventNum(int exploredNormalEventNum) {
        this.exploredNormalEventNum = exploredNormalEventNum;
    }

    public void increaseExploredNormalEventNum() {
        this.exploredNormalEventNum++;
    }

    public List<EventInfo> getEventInfoList() {
        return eventInfoList;
    }

    public void setEventInfoList(List<EventInfo> eventInfoList) {
        this.eventInfoList = eventInfoList;
    }

    public int getEliteEventId() {
        return eliteEventId;
    }

    public void setEliteEventId(int eliteEventId) {
        this.eliteEventId = eliteEventId;
    }

    public int getGenerateEventNum() {
        return generateEventNum;
    }

    public void setGenerateEventNum(int generateEventNum) {
        this.generateEventNum = generateEventNum;
    }
}
